package cn.kgc.ssm.web.service.impl;

import cn.kgc.ssm.web.mapper.*;
import cn.kgc.ssm.web.response.ResponseResult;
import cn.kgc.ssm.web.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date  2024/8/6
 * @description
 */
@Service
public class EchartsServiceImpl implements EchartsService {

    @Autowired
    private EchartsMapper echartsMapper;

    @Autowired
    private ActiveMapper activeMapper;

    @Autowired
    private MemberMapper memberMapper;

    @Autowired
    private MessageMapper messageMapper;

    @Autowired
    private RecruitMapper recruitMapper;

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public ResponseResult lineData() {

        List<Map<String,Object>>  result =   echartsMapper.selectLineData();
        return ResponseResult.success().data(result);
    }

    @Override
    public ResponseResult dataPanel() {

        //  1.  新活动数  近一周
        Long  activeNumber =  activeMapper.activePanel();
        // 2.  新会员   近一月
        Long memberNumber =    memberMapper.memberPanel();
        // 3.  新留言   近一周
        Long messageNumber =  messageMapper.messagePanel();
        // 2.  新职位  近一月
        Long recruitNumber =   recruitMapper.recruitPanel();
        HashMap<String, Object> result = new HashMap<>();

        result.put("active",activeNumber);
        result.put("member",memberNumber);
        result.put("message",messageNumber);
        result.put("recruit",recruitNumber);
        return ResponseResult.success().data(result);
    }

    @Override
    public ResponseResult dataPie() {

        List<Map<String, Object>> maps = orderMapper.orderPieData();
        return ResponseResult.success().data(maps);
    }
}
